<%--
  Created by IntelliJ IDEA.
  User: hongcy
  Date: 16-3-20
  Time: 下午9:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ include file="/include/taglib.jsp" %>
<div style="padding:20px 0px;">
    <form method="post" action="${ctx}/mulanweb/admin/coupon/save" id="ff">
        <table cellspacing="5" style="margin: 0 auto">
            <tr>
                <td>使用类别:</td>
                <td><input type="checkbox" value="31" name="type" checked="checked" id="qy" onclick="getTypeId()"/>
                    <label for="qy">门票券票</label>&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="checkbox" value="32" name="type" id="gr" onclick="getTypeId()"/>
                    <label for="gr">包车陪游</label>
                    <input type="hidden" name="typeId" id="typeId" value="31" />
            </tr>
            <tr>
                <td>生效时间:</td>
                <td><input name="startTime" class="easyui-datetimebox" data-options="required:true" style="width:200px" /></td>
            </tr>
            <tr>
                <td>失效时间:</td>
                <td><input name="endTime" class="easyui-datetimebox" data-options="required:true" style="width:200px" /></td>
            </tr>
            <tr>
                <td>生成数量:</td>
                <td><input class="easyui-numberbox" name="totalNumber" data-options="required:true" style="width:200px"></td>
            </tr>
            <tr>
                <td colspan="2">优惠券面额: 满 <input name="satisfyValue" class="easyui-numberbox" data-options="required:true" style="width:60px"> 减 <input name="value" class="easyui-numberbox" style="width:60px" data-options="required:true" ></td>
            </tr>
            <tr>
                <td>所属者:</td>
                <td><input name="extensionId" id="epId" style="width:200px" value="1"/> </td>
            </tr>
        </table>
    </form>
    <script>
        function getTypeId(){
            var typeId = $("input:checkbox[name=type]:checked");
            var typeIds = [] ;
            var i = 0 ;
            while(i <typeId.length){
                typeIds.push($(typeId[i]).val())
                i++;
            }
            if(typeIds.length==2){
                $("#typeId").val(33);
            }else if(typeId == 1){
                $("#typeId").val(typeId);
            }
        }
        $(function(){
            $("#epId").combobox({
                url: '${ctx}/mulanweb/admin/extension_personnel/search',
                valueField: 'Id',
                textField: 'NameCn',
                editable: true,
                required:true,
                queryParams: {
                    PageSize: 100,
                    PageNumber: 1
                },
                loadFilter: function (data) {
                    var result = [];
                    var currentSize = data.PageSize;
                    var totalSize = data.TotalRow;
                    if (data.ReturnCode == 1 && currentSize >= totalSize) {
                        if (data.DataList.length > 0) {
                            for (var tt = 0; tt < data.DataList.length; tt++) {
                                result.push({Id: data.DataList[tt].Id, NameCn: data.DataList[tt].Name});
                            }
                        }
                    } else {
                        Constant.showMessage("信息已超过最大值");
                    }
                    return result;
                },
                onChange: function (newV, oldV) {

                }
            });
        })
    </script>
</div>
